load("@fbcode_macros//build_defs:cpp_binary.bzl", "cpp_binary")
load("@fbcode_macros//build_defs:cpp_library.bzl", "cpp_library")
load("@fbcode_macros//build_defs:cpp_unittest.bzl", "cpp_unittest")
load("@fbcode_macros//build_defs:export_files.bzl", "export_file")
load("@fbcode_macros//build_defs:thrift_library.bzl", "thrift_library")
load("@fbsource//tools/target_determinator/macros:ci_sandcastle.bzl", "ci_sandcastle")
load("//fboss/agent:sai.bzl", "sai_main_all")
load("//fboss/thriftpath_plugin/facebook:thriftpath_plugin.bzl", "thrift_plugin_thriftpath")

oncall("fboss_agent_push")

thrift_library(
    name = "switch_config",
    go_thrift_namespaces = {
        "switch_config.thrift": "neteng.fboss.switch_config",
    },
    languages = [
        "cpp2",
        "go",
        "py-deprecated",
        "py3-deprecated",
        "python",
        "py-deprecated-asyncio",
        "rust",
    ],
    no_plugin_deps = ["//thrift/annotation:all"],
    py3_namespace = "neteng.fboss",
    py_asyncio_base_module = "neteng.fboss.asyncio",
    py_base_module = "neteng.fboss",
    thrift_cpp2_options = "json,reflection",
    thrift_py_options = "json,sort_keys",
    thrift_rust_options = [
        "deprecated_default_enum_min_i32",
        "serde",
    ],
    thrift_srcs = {"switch_config.thrift": []},
    deps = [
        "//fboss/agent/if:common",
        "//fboss/agent/if:mpls",
        "//fboss/lib/if:fboss_common",
        "//thrift/annotation:cpp",
        "//thrift/annotation:python",
        "//thrift/annotation:thrift",
    ],
)

thrift_library(
    name = "agent_config",
    go_thrift_namespaces = {
        "agent_config.thrift": "neteng.fboss.agent_config",
    },
    languages = [
        "cpp2",
        "go",
        "py-deprecated",
        "py-deprecated-asyncio",
        "py3-deprecated",
        "rust",
        "python",
    ],
    plugins = [
        thrift_plugin_thriftpath(),
    ],
    py3_namespace = "neteng.fboss",
    py_asyncio_base_module = "neteng.fboss.asyncio",
    py_base_module = "neteng.fboss",
    thrift_cpp2_options = "json,reflection",
    thrift_py_options = "json,sort_keys",
    thrift_rust_options = [
        "deprecated_default_enum_min_i32",
        "serde",
    ],
    thrift_srcs = {"agent_config.thrift": []},
    deps = [
        ":platform_config",
        ":switch_config",
        "//thrift/annotation:thrift",
    ],
)

thrift_library(
    name = "agent_info",
    go_thrift_namespaces = {
        "agent_info.thrift": "neteng.fboss.agent_info",
    },
    languages = [
        "cpp2",
        "py-deprecated",
        "py3-deprecated",
        "py-deprecated-asyncio",
        "go",
        "rust",
        "python",
    ],
    plugins = [
        thrift_plugin_thriftpath(),
    ],
    py3_namespace = "neteng.fboss",
    py_asyncio_base_module = "neteng.fboss.asyncio",
    py_base_module = "neteng.fboss",
    rust_gen_metadata = True,
    thrift_cpp2_options = "json,reflection",
    thrift_py_options = "json,sort_keys",
    thrift_srcs = {"agent_info.thrift": []},
    deps = [],
)

thrift_library(
    name = "platform_config",
    cpp2_deps = [
        "//fboss/lib/phy:phy-cpp2-types",
        "//fboss/qsfp_service/if:transceiver-cpp2-types",
        ":fboss-types",
    ],
    cpp2_headers = ["platforms/common/PlatformMapping.h"],
    go_thrift_namespaces = {
        "platform_config.thrift": "neteng.fboss.platform_config",
    },
    languages = [
        "cpp2",
        "go",
        "py-deprecated",
        "py3-deprecated",
        "py-deprecated-asyncio",
        "rust",
        "python",
    ],
    py3_namespace = "neteng.fboss.platform_config",
    py_asyncio_base_module = "neteng.fboss.asyncio",
    py_base_module = "neteng.fboss",
    thrift_cpp2_options = "json,reflection",
    thrift_py_options = "json,sort_keys",
    thrift_rust_options = [
        "deprecated_default_enum_min_i32",
        "serde",
    ],
    thrift_srcs = {"platform_config.thrift": []},
    deps = [
        ":switch_config",
        "//fboss/agent/hw/bcm:bcm_config",
        "//fboss/agent/hw/config:asic_config_v2",
        "//fboss/agent/hw/sai/config:asic_config",
        "//fboss/lib/phy:phy",
        "//fboss/qsfp_service/if:transceiver",
    ],
)

thrift_library(
    name = "switch_state",
    go_thrift_namespaces = {
        "switch_state.thrift": "neteng.fboss.switch_state",
    },
    languages = [
        "cpp2",
        "py-deprecated",
        "py3-deprecated",
        "py-deprecated-asyncio",
        "go",
        "rust",
        "python",
    ],
    plugins = [
        thrift_plugin_thriftpath(),
    ],
    py3_namespace = "neteng.fboss",
    py_asyncio_base_module = "neteng.fboss.asyncio",
    py_base_module = "neteng.fboss",
    rust_gen_metadata = True,
    thrift_cpp2_options = "json,reflection",
    thrift_py_options = "json,sort_keys",
    thrift_srcs = {"switch_state.thrift": []},
    deps = [
        ":switch_config",
        "//common/network/if:if",
        "//fboss/agent/if:common",
        "//fboss/agent/if:ctrl",
        "//fboss/lib/phy:phy",
        "//fboss/mka_service/if:mka_structs",
        "//fboss/qsfp_service/if:transceiver",
        "//thrift/annotation:thrift",
    ],
)

thrift_library(
    name = "switch_reachability",
    go_thrift_namespaces = {
        "switch_reachability.thrift": "neteng.fboss.switch_reachability",
    },
    languages = [
        "cpp2",
        "py-deprecated",
        "py3-deprecated",
        "py-deprecated-asyncio",
        "go",
        "rust",
        "python",
    ],
    plugins = [
        thrift_plugin_thriftpath(),
    ],
    py3_namespace = "neteng.fboss",
    py_asyncio_base_module = "neteng.fboss.asyncio",
    py_base_module = "neteng.fboss",
    rust_gen_metadata = True,
    thrift_cpp2_options = "json,reflection",
    thrift_py_options = "json,sort_keys",
    thrift_srcs = {"switch_reachability.thrift": []},
    deps = [],
)

thrift_library(
    name = "validated_shell_commands",
    languages = [
        "cpp2",
        "py3-deprecated",
        "python",
    ],
    py3_namespace = "neteng.fboss",
    thrift_cpp2_options = "json",
    thrift_srcs = {"validated_shell_commands.thrift": []},
)

thrift_library(
    name = "agent_stats",
    cpp2_deps = [
        "//folly/container:f14_hash",
        "//folly:fbstring",
    ],
    go_thrift_namespaces = {
        "agent_stats.thrift": "neteng.fboss.agent_stats",
    },
    languages = [
        "cpp2",
        "py-deprecated",
        "go",
        "py3-deprecated",
        "py-deprecated-asyncio",
        "rust",
        "python",
    ],
    no_plugin_deps = ["//thrift/annotation:all"],
    py3_namespace = "neteng.fboss",
    py_asyncio_base_module = "neteng.fboss.asyncio",
    py_base_module = "neteng.fboss",
    thrift_cpp2_options = [
        "json",
        "reflection",
    ],
    thrift_srcs = {"agent_stats.thrift": []},
    deps = [
        ":switch_config",
        "//fboss/agent/hw:hardware_stats",
        "//fboss/agent/if:asic_temp",
        "//fboss/lib/phy:phy",
        "//thrift/annotation:cpp",
    ],
)

cpp_library(
    name = "constants",
    headers = [
        "Constants.h",
    ],
    exported_deps = [
        "//folly:range",
    ],
)

cpp_library(
    name = "setup_thrift",
    srcs = [
        "SetupThrift.cpp",
        "facebook/SetupThrift.cpp",
    ],
    headers = [
        "facebook/SetupThrift.h",
    ],
    exported_deps = [
        ":load_agent_config",
        "//common/services/cpp:thrift_acl_checker_module_config",
        "//common/services/cpp:thrift_aclchecker_handler_factory",
        "//common/services/cpp:tls",
        "//fb303:export_type",
        "//fb303:service_data",
        "//fboss/lib:thrift_method_rate_limit",
        "//folly:network_address",
        "//folly/io/async:async_base",
        "//folly/logging:logging",
        "//thrift/lib/cpp2:server",
        "//thrift/lib/cpp2/async:multiplex_async_processor",
        "//thrift/lib/cpp2/async:pooled_request_channel",
        "//thrift/lib/cpp2/async:rocket_client_channel",
    ],
    exported_external_deps = [
        "gflags",
    ],
)

cpp_library(
    name = "fboss_init_h",
    headers = [
        "FbossInit.h",
    ],
    exported_deps = [
        "//fboss/lib/platforms:platform_mode",
    ],
)

cpp_library(
    name = "fboss_init",
    srcs = [
        "facebook/FbossInit.cpp",
    ],
    exported_deps = [
        ":fboss_init_h",
        "//common/fbwhoami:fb_who_am_i",
        "//common/init:init",
        "//common/services/cpp:build_values",
        "//fb303:logging",
    ],
)

cpp_library(
    name = "dhcpv4_options_of_interest",
    headers = ["DHCPv4OptionsOfInterest.h"],
)

cpp_library(
    name = "fboss_common_init_h",
    headers = [
        "CommonInit.h",
    ],
    exported_deps = [
        "//folly/io/async:async_signal_handler",
    ],
)

cpp_library(
    name = "fboss_common_init",
    srcs = [
        "CommonInit.cpp",
        "facebook/CommonInit.cpp",
    ],
    headers = [
        "CommonInit.h",
    ],
    exported_deps = [
        ":fboss_init",  # @manual
        ":fboss_init_h",
        ":load_agent_config",
        ":platform_base",
        "//common/base:build_info",
        "//common/config:config",
        "//fb303:service_data",
        "//fboss/facebook/bitsflow:bitsflow_helper",
        "//folly:conv",
        "//folly/io/async:async_signal_handler",
        "//folly/logging:logging",
    ],
    exported_external_deps = [
        "gflags",
    ],
)

# TODO: deprecate main-common as it leads to a dependency mess
cpp_library(
    name = "main-common",
    srcs = [
        "Main.cpp",
    ],
    headers = [
        "Main.h",
    ],
    undefined_symbols = True,
    exported_deps = [
        ":agent_initializer_h",
        "//folly/logging:init",
    ],
)

cpp_library(
    name = "main-bcm",
    srcs = [
        "Main.cpp",
        "facebook/Main.cpp",
    ],
    exported_deps = [
        ":agent_initializer_h",
        ":fboss_common_init",
        "//fboss/agent/facebook:bcm_version",  # @manual
        "//fboss/agent/facebook:version_h",
        "//folly/logging:init",
    ],
)

cpp_library(
    name = "fake_main",
    srcs = [
        "CommonInit.cpp",
        "Main.cpp",
    ],
    exported_deps = [
        ":agent_initializer_h",
        ":fboss_init_h",
        ":load_agent_config",
        ":platform_base",
        "//fb303:service_data",
        "//folly/io/async:async_signal_handler",
        "//folly/logging:init",
        "//folly/logging:logging",
        "//neteng/fboss/emulation:main",  # @manual
    ],
    exported_external_deps = [
        "gflags",
    ],
)

cpp_library(
    name = "buffer_utils",
    srcs = [
        "BufferUtils.cpp",
    ],
    headers = [
        "BufferUtils.h",
    ],
    exported_deps = [
        ":utils",
        "//fboss/agent/state:state",
    ],
)

cpp_library(
    name = "dsfnode_utils",
    srcs = [
        "DsfNodeUtils.cpp",
    ],
    headers = [
        "DsfNodeUtils.h",
    ],
    exported_deps = [
        ":agent_config-cpp2-types",
        ":fboss-error",
        ":load_agent_config",
        ":switch_config-cpp2-types",
    ],
)

cpp_library(
    name = "switchinfo_utils",
    srcs = [
        "SwitchInfoUtils.cpp",
    ],
    headers = [
        "SwitchInfoUtils.h",
    ],
    exported_deps = [
        ":fboss-error",
        ":fboss-types",
        ":load_agent_config",
        ":switch_config-cpp2-types",
        ":switch_state-cpp2-types",
        "//fboss/agent/if:ctrl-cpp2-types",
        "//folly:range",
        "//folly/logging:logging",
    ],
)

cpp_library(
    name = "voq_utils",
    srcs = [
        "VoqUtils.cpp",
    ],
    headers = [
        "VoqUtils.h",
    ],
    exported_deps = [
        ":agent_features",
        ":switch_config-cpp2-types",
        "//fboss/agent/hw/switch_asics:switch_asics",
        "//fboss/agent/state:state",
        "//folly:network_address",
    ],
    exported_external_deps = [
        ("boost", None, "boost_container"),
    ],
)

cpp_library(
    name = "address_utils",
    headers = [
        "AddressUtil.h",
    ],
    exported_deps = [
        "//common/network/if:if-cpp2-types",
        "//folly:network_address",
    ],
)

cpp_library(
    name = "packet_observer",
    srcs = [
        "PacketObserver.cpp",
    ],
    headers = [
        "PacketObserver.h",
    ],
    exported_deps = [
        ":fboss-error",
        "//folly:spin_lock",
        "//folly:synchronized",
        "//folly/logging:logging",
    ],
    exported_external_deps = [
        "boost",
    ],
)

cpp_library(
    name = "l2learn_event_observer",
    srcs = [
        "L2LearnEventObserver.cpp",
    ],
    headers = [
        "L2LearnEventObserver.h",
    ],
    exported_deps = [
        ":fboss-error",
        "//folly:spin_lock",
        "//folly:synchronized",
        "//folly/logging:logging",
    ],
    exported_external_deps = [
        "boost",
    ],
)

cpp_library(
    name = "enum_utils",
    headers = ["EnumUtils.h"],
    exported_deps = [
        "//folly/logging:logging",
        "//thrift/lib/cpp/util:enum_utils",
    ],
)

cpp_library(
    name = "asic_utils",
    srcs = [
        "AsicUtils.cpp",
    ],
    exported_deps = [
        "//fboss/agent/hw/switch_asics:switch_asics",
    ],
)

cpp_library(
    name = "stat_printers",
    srcs = [
        "StatPrinters.cpp",
    ],
    headers = [
        "StatPrinters.h",
    ],
    exported_deps = [
        "//fboss/agent/hw:hardware_stats-cpp2-types",
        "//fboss/lib/phy:phy-cpp2-types",
        "//thrift/lib/cpp2/protocol:protocol",
    ],
)

cpp_library(
    name = "utils",
    srcs = [
        "AlpmUtils.cpp",
        "LabelFibUtils.cpp",
        "Utils.cpp",
        "facebook/Utils.cpp",
    ],
    exported_deps = [
        "fbsource//third-party/re2:re2",
        ":agent_features",
        ":asic_utils",
        ":fboss-error",
        ":fboss-types",
        ":fsdb_helper",
        ":hwswitch_matcher",
        ":switch_config-cpp2-types",
        ":switch_state-cpp2-types",
        ":switchid_scope_resolver",
        "//common/network:util",
        "//fboss/agent/hw:hw_switch_fb303_stats",
        "//fboss/agent/if:ctrl-cpp2-types",
        "//fboss/agent/platforms/common/janga800bic:janga800bic_platform_mapping",
        "//fboss/agent/platforms/common/meru400bfu:meru400bfu_platform_mapping",
        "//fboss/agent/platforms/common/meru400bia:meru400bia_platform_mapping",
        "//fboss/agent/platforms/common/meru400biu:meru400biu_platform_mapping",
        "//fboss/agent/platforms/common/meru800bfa:meru800bfa_platform_mapping",
        "//fboss/agent/platforms/common/meru800bia:meru800bia_platform_mapping",
        "//fboss/agent/state:state",
        "//fboss/fsdb/if:fsdb_oper-cpp2-types",
        "//folly:file_util",
        "//folly:network_address",
        "//folly:range",
        "//folly:subprocess",
        "//folly/json:dynamic",
        "//folly/lang:bits",
        "//folly/logging:logging",
        "//folly/system:thread_name",
        "//thrift/lib/cpp/util:enum_utils",
        "//thrift/lib/cpp2/protocol:protocol",
    ],
    exported_external_deps = [
        "boost",
        ("boost", None, "boost_container"),
        ("boost", None, "boost_filesystem"),
    ],
)

cpp_library(
    name = "lacp_types",
    srcs = [
        "LacpTypes.cpp",
    ],
    exported_deps = [
        ":fboss-error",
        ":switch_state-cpp2-types",
        "//fboss/agent/if:ctrl-cpp2-types",
        "//folly:conv",
        "//folly:network_address",
        "//folly:range",
        "//folly/io:iobuf",
        "//folly/json:dynamic",
    ],
)

cpp_library(
    name = "mka_service_ports",
    srcs = [
        "MKAServicePorts.cpp",
    ],
    headers = [
        "MKAServicePorts.h",
    ],
    exported_external_deps = [
        "gflags",
    ],
)

cpp_library(
    name = "stats",
    srcs = [
        "AggregatePortStats.cpp",
        "InterfaceStats.cpp",
        "PortStats.cpp",
        "SwitchStats.cpp",
        "facebook/AggregatePortStats.cpp",
        "facebook/SwitchStats.cpp",
    ],
    exported_deps = [
        ":agent_stats-cpp2-types",
        ":fboss-types",
        "//fb303:service_data",
        "//fb303:thread_cached_service_data",
        "//fb303/detail:quantile_stat_wrappers",
        "//fboss/agent/state:state",
        "//fboss/lib:common_utils",
        "//folly:memory",
        "//folly:range",
        "//folly:utility",
        "//folly/concurrency:concurrent_hash_map",
        "//folly/logging:logging",
    ],
    exported_external_deps = [
        "boost",
    ],
)

cpp_library(
    name = "apply_thrift_config",
    srcs = ["ApplyThriftConfig.cpp"],
    exported_deps = [
        ":agent_features",
        ":asic_utils",
        ":buffer_utils",
        ":core",
        ":fboss-error",
        ":hw_asic_table",
        ":lacp_types",
        ":loadbalancer_utils",
        ":route_update_wrapper",
        ":switch_config-cpp2-types",
        ":switchid_scope_resolver",
        ":switchinfo_utils",
        ":utils",
        ":voq_utils",
        "//fboss/agent/hw/switch_asics:switch_asics",
        "//fboss/agent/if:mpls-cpp2-types",
        "//fboss/agent/platforms/common:platform_mapping",
        "//fboss/agent/rib:fib_updater",
        "//fboss/agent/rib:network_to_route_map",
        "//fboss/agent/rib:standalone_rib",
        "//fboss/agent/state:state",
        "//fboss/agent/state:state_utils",
        "//fboss/lib/config:fboss_config_utils",
        "//fboss/thrift_cow/nodes:nodes",
        "//folly:file_util",
        "//folly:range",
        "//folly/gen:base",
    ],
    exported_external_deps = [
        ("boost", None, "boost_container"),
    ],
)

cpp_library(
    name = "phy_snapshot_lib",
    srcs = ["PhySnapshotManager.cpp"],
    headers = [
        "PhySnapshotManager.h",
    ],
    exported_deps = [
        "//fboss/agent/state:state",
        "//fboss/lib/link_snapshots:async_filewriter_factory",
        "//fboss/lib/link_snapshots:snapshot_manager",
        "//fboss/lib/phy:phy-cpp2-types",
    ],
)

cpp_library(
    name = "fsdb_adapted_sub_manager",
    srcs = [
        "FsdbAdaptedSubManager.cpp",
    ],
    headers = [
        "FsdbAdaptedSubManager.h",
    ],
    exported_deps = [
        "//fboss/agent/state:state",
        "//fboss/fsdb/client:fsdb_sub_manager",
        "//fboss/fsdb/if:fsdb_model",
        "//fboss/thrift_cow/storage:cow_storage",
    ],
)

cpp_library(
    name = "fib_helpers",
    srcs = [
        "FibHelpers.cpp",
    ],
    exported_deps = [
        ":fboss-types",
        "//fboss/agent/rib:standalone_rib",
        "//fboss/agent/state:state",
        "//folly:network_address",
    ],
)

cpp_library(
    name = "ecmp_resource_manager",
    srcs = [
        "EcmpResourceManager.cpp",
        "EcmpResourceManagerConfig.cpp",
    ],
    exported_deps = [
        ":agent_features",
        ":fboss-types",
        ":fib_helpers",
        ":stats",
        ":switch_config-cpp2-types",
        ":utils",
        "//fboss/agent/hw/switch_asics:switch_asics",
        "//fboss/agent/state:state",
        "//fboss/lib:ref_map",
    ],
)

cpp_library(
    name = "shel_manager",
    srcs = [
        "ShelManager.cpp",
    ],
    exported_deps = [
        "fbsource//third-party/googletest:gtest",
        ":fboss-types",
        ":fib_helpers",
        ":utils",
        "//fboss/agent/state:state",
        "//folly:synchronized",
    ],
)

cpp_library(
    name = "state_delta_logger",
    srcs = [
        "StateDeltaLogger.cpp",
    ],
    exported_deps = [
        ":agent_features",
        ":async_logger_base",
        "//fboss/agent/state:state",
        "//fboss/fsdb/if:fsdb_oper-cpp2-types",
        "//folly/logging:logging",
    ],
)

cpp_library(
    name = "hw_switch_thrift_client_table",
    srcs = [
        "HwSwitchThriftClientTable.cpp",
    ],
    headers = [
        "HwSwitchThriftClientTable.h",
    ],
    exported_deps = [
        ":fboss-error",
        ":fboss-types",
        "//fboss/agent/if:hw_ctrl-cpp2-services",
        "//folly/io/async:async_base",
        "//folly/io/async:scoped_event_base_thread",
        "//folly/logging:logging",
        "//thrift/lib/cpp2/async:pooled_request_channel",
        "//thrift/lib/cpp2/async:reconnecting_request_channel",
        "//thrift/lib/cpp2/async:retrying_request_channel",
        "//thrift/lib/cpp2/async:rocket_client_channel",
    ],
)

cpp_library(
    name = "core",
    srcs = [
        "AclNexthopHandler.cpp",
        "ApplyThriftConfig.cpp",
        "ArpCache.cpp",
        "ArpHandler.cpp",
        "DHCPv4Handler.cpp",
        "DHCPv6Handler.cpp",
        "DsfSession.cpp",
        "DsfStateUpdaterUtil.cpp",
        "DsfSubscriber.cpp",
        "DsfSubscription.cpp",
        "DsfUpdateValidator.cpp",
        "EncapIndexAllocator.cpp",
        "FabricConnectivityManager.cpp",
        "FabricLinkMonitoring.cpp",
        "FabricLinkMonitoringManager.cpp",
        "FsdbSyncer.cpp",
        "HwAsicTable.cpp",
        "HwSwitchConnectionStatusTable.cpp",
        "IPHeaderV4.cpp",
        "IPv4Handler.cpp",
        "IPv6Handler.cpp",
        "LacpController.cpp",
        "LacpMachines.cpp",
        "LacpTypes.cpp",
        "LinkAggregationManager.cpp",
        "LinkConnectivityProcessor.cpp",
        "LldpManager.cpp",
        "LoadBalancerConfigApplier.cpp",
        "LookupClassRouteUpdater.cpp",
        "LookupClassUpdater.cpp",
        "MKAServiceManager.cpp",
        "MPLSHandler.cpp",
        "MacTableManager.cpp",
        "MacTableUtils.cpp",
        "MirrorManager.cpp",
        "MirrorManagerImpl.cpp",
        "MultiHwSwitchHandler.cpp",
        "MultiSwitchFb303Stats.cpp",
        "MultiSwitchPacketStreamMap.cpp",
        "NdpCache.cpp",
        "NeighborUpdater.cpp",
        "NeighborUpdaterImpl.cpp",
        "NeighborUpdaterNoopImpl.cpp",
        "PortUpdateHandler.cpp",
        "RemoteNeighborUpdater.cpp",
        "ResolvedNexthopMonitor.cpp",
        "ResolvedNexthopProbe.cpp",
        "ResolvedNexthopProbeScheduler.cpp",
        "ResourceAccountant.cpp",
        "RouteUpdateLogger.cpp",
        "RouteUpdateLoggingPrefixTracker.cpp",
        "StaticL2ForNeighborObserver.cpp",
        "StaticL2ForNeighborSwSwitchUpdater.cpp",
        "StaticL2ForNeighborUpdater.cpp",
        "SwSwitch.cpp",
        "SwSwitchRouteUpdateWrapper.cpp",
        "SwitchInfoTable.cpp",
        "SwitchStats.cpp",
        "SwitchStatsObserver.cpp",
        "TeFlowNexthopHandler.cpp",
        "TunIntf.cpp",
        "TunManager.cpp",
        "facebook/PacketLogger.cpp",
        "facebook/RouteUpdateLogger.cpp",
        "facebook/SwSwitch.cpp",
        "facebook/SwitchStats.cpp",
        "ndp/IPv6RouteAdvertiser.cpp",
    ],
    headers = [
        "FsdbSyncer.h",
        "HwAsicTable.h",
        "HwSwitchConnectionStatusTable.h",
        "LockPolicy.h",
        "MultiSwitchFb303Stats.h",
        "MultiSwitchPacketStreamMap.h",
        "NeighborCache.h",
        "NeighborCacheEntry.h",
        "NeighborCacheImpl.h",
        "NeighborCacheImpl-defs.h",
        "NeighborTableDeltaCallbackGenerator.h",
        "NeighborUpdater-defs.h",
        "NlError.h",
        "PacketLogger.h",
        "SwitchInfoTable.h",
        "TunIntfBase.h",
        "facebook/ScubaRouteLogger.h",
    ],
    exported_deps = [
        "fbsource//third-party/googletest:gtest",
        "fbsource//third-party/re2:re2",
        ":address_utils",
        ":agent_dir_util",
        ":agent_features",
        ":agent_fsdb_sync_manager",
        ":agent_info-cpp2-types",
        ":agent_stats-cpp2-types",
        ":asic_utils",
        ":buffer_utils",
        ":build_info_wrapper",
        ":constants",
        ":dhcpv4_options_of_interest",
        ":dsfnode_utils",
        ":ecmp_resource_manager",
        ":fboss-error",
        ":fboss-types",
        ":fboss_event_base",
        ":fib_helpers",
        ":fsdb_adapted_sub_manager",
        ":hw_switch_handler",
        ":hw_switch_thrift_client_table",
        ":hwswitchcallback",
        ":l2learn_event_observer",
        ":load_agent_config",
        ":loadbalancer_utils",
        ":mka_service_ports",
        ":monolithic_hw_switch_handler",
        ":packet",
        ":packet_observer",
        ":phy_snapshot_lib",
        ":route_update_wrapper",
        ":shel_manager",
        ":state_delta_logger",
        ":state_observer",
        ":stats",
        ":sw_switch_warmboot_helper",
        ":switch_config-cpp2-types",
        ":switch_reachability-cpp2-types",
        ":switch_state-cpp2-types",
        ":switchid_scope_resolver",
        ":switchinfo_utils",
        ":tx_packet_utils",
        ":utils",
        ":voq_utils",
        "//common/fbwhoami:fb_who_am_i",
        "//common/network:util",
        "//common/strings:uuid",
        "//common/time:time",
        "//common/time:time_core",
        "//configerator/distribution/api:api",
        "//fb303:service_data",
        "//fb303:thread_cached_service_data",
        "//fb303/detail:quantile_stat_wrappers",
        "//fboss/agent/capture:capture",
        "//fboss/agent/hw:hw_cpu_fb303_stats",
        "//fboss/agent/hw:hw_switch_fb303_stats",
        "//fboss/agent/hw/switch_asics:switch_asics",
        "//fboss/agent/if:ctrl-cpp2-services",
        "//fboss/agent/if:ctrl-cpp2-types",
        "//fboss/agent/if:hw_ctrl-cpp2-services",
        "//fboss/agent/if:mpls-cpp2-types",
        "//fboss/agent/if:multiswitch_ctrl-cpp2-services",
        "//fboss/agent/lldp:lldp",
        "//fboss/agent/lldp:lldp_structs-cpp2-types",
        "//fboss/agent/packet:ether_type",
        "//fboss/agent/packet:ipproto",
        "//fboss/agent/packet:packet",
        "//fboss/agent/packet:packet_factory",
        "//fboss/agent/packet:pktutil",
        "//fboss/agent/platforms/common:platform_mapping",
        "//fboss/agent/platforms/common:platform_mapping_utils",
        "//fboss/agent/platforms/common/janga800bic:janga800bic_platform_mapping",
        "//fboss/agent/rib:fib_updater",
        "//fboss/agent/rib:network_to_route_map",
        "//fboss/agent/rib:standalone_rib",
        "//fboss/agent/state:nodebase",
        "//fboss/agent/state:state",
        "//fboss/agent/state:state_update",
        "//fboss/agent/state:state_utils",
        "//fboss/agent/thrift_packet_stream:bidirectional_packet_stream",
        "//fboss/facebook/bitsflow:bitsflow_helper",
        "//fboss/fsdb/client:fsdb_pub_sub",
        "//fboss/fsdb/client:fsdb_stream_client",
        "//fboss/fsdb/client:fsdb_sub_manager",
        "//fboss/fsdb/common:flags",
        "//fboss/fsdb/if:fsdb_common-cpp2-types",
        "//fboss/fsdb/if:fsdb_model",
        "//fboss/fsdb/if:fsdb_oper-cpp2-types",
        "//fboss/lib:alert_logger",
        "//fboss/lib:common_file_utils",
        "//fboss/lib:common_utils",
        "//fboss/lib:exponential_back_off",
        "//fboss/lib:hw_write_behavior",
        "//fboss/lib:radix_tree",
        "//fboss/lib:thread_heartbeat",
        "//fboss/lib/config:fboss_config_utils",
        "//fboss/lib/link_snapshots:async_filewriter_factory",
        "//fboss/lib/phy:phy-cpp2-types",
        "//fboss/lib/phy:prbs-cpp2-types",
        "//fboss/lib/platforms:product-info",
        "//fboss/lib/restart_tracker:restart_time_tracker",
        "//fboss/lib/thrift_service_client:thrift-service-client",
        "//fboss/thrift_cow/nodes:nodes",
        "//fboss/thrift_cow/nodes:serializer",
        "//fboss/thrift_cow/storage:cow_storage",
        "//fboss/util:logging",
        "//folly:conv",
        "//folly:demangle",
        "//folly:exception_string",
        "//folly:file_util",
        "//folly:intrusive_list",
        "//folly:map_util",
        "//folly:memory",
        "//folly:network_address",
        "//folly:random",
        "//folly:range",
        "//folly:shared_mutex",
        "//folly:spin_lock",
        "//folly:string",
        "//folly:synchronized",
        "//folly:thread_local",
        "//folly:utility",
        "//folly/concurrency:concurrent_hash_map",
        "//folly/container:f14_hash",
        "//folly/coro:bounded_queue",
        "//folly/executors:io_thread_pool_executor",
        "//folly/executors/thread_factory:named_thread_factory",
        "//folly/futures:core",
        "//folly/gen:base",
        "//folly/io:iobuf",
        "//folly/io/async:async_base",
        "//folly/io/async:scoped_event_base_thread",
        "//folly/json:dynamic",
        "//folly/lang:bits",
        "//folly/lang:c_string",
        "//folly/logging:logging",
        "//folly/system:thread_name",
        "//scribe/client:scribe_client",
        "//scribe/client:scribe_client_no_sr",
        "//servicerouter/client/cpp2:cpp2",
        "//thrift/lib/cpp/util:enum_utils",
        "//thrift/lib/cpp2/async:request_channel",
        "//thrift/lib/cpp2/protocol:protocol",
        "//thrift/lib/cpp2/util:util",
    ],
    exported_external_deps = [
        "boost",
        "gflags",
        "glog",
        ("boost", None, "boost_container"),
        ("iproute2", None, "netlink"),
        ("libnl", None, "nl-route-3"),
    ],
)

cpp_library(
    name = "handler",
    srcs = [
        "ThriftHandler.cpp",
    ],
    exported_deps = [
        ":address_utils",
        ":agent_features",
        ":core",
        ":fboss-error",
        ":fboss-types",
        ":fboss_event_base",
        ":fib_helpers",
        ":hw_asic_table",
        ":hw_switch_thrift_client_table",
        ":packet",
        ":stats",
        ":switch_config-cpp2-types",
        ":switchid_scope_resolver",
        ":thrifthandler_utils",
        ":utils",
        "//common/fb303/cpp:fb303",
        "//common/logging:logging",
        "//fb303:service_data",
        "//fboss/agent/capture:capture",
        "//fboss/agent/hw:hardware_stats-cpp2-types",
        "//fboss/agent/hw/mock:pkt",
        "//fboss/agent/if:ctrl-cpp2-services",
        "//fboss/agent/if:ctrl-cpp2-types",
        "//fboss/agent/platforms/common:platform_mapping",
        "//fboss/agent/rib:fib_updater",
        "//fboss/agent/state:nodebase",
        "//fboss/agent/state:state",
        "//fboss/agent/state:state_utils",
        "//fboss/lib:log_thrift_call",
        "//fboss/lib/config:fboss_config_utils",
        "//fboss/lib/phy:phy-cpp2-types",
        "//fboss/lib/phy:prbs-cpp2-types",
        "//folly:network_address",
        "//folly:range",
        "//folly:string",
        "//folly:synchronized",
        "//folly/container:f14_hash",
        "//folly/functional:partial",
        "//folly/io:iobuf",
        "//folly/logging:logging",
        "//thrift/lib/cpp/server:server_event_handler",
        "//thrift/lib/cpp/util:enum_utils",
        "//thrift/lib/cpp2:server",
        "//thrift/lib/cpp2/async:duplex_channel",
    ],
)

cpp_library(
    name = "test_thrift_handler",
    srcs = [
        "TestThriftHandler.cpp",
    ],
    headers = [
        "TestThriftHandler.h",
    ],
    exported_deps = [
        ":core",
        ":handler",
        ":utils",
        "//fboss/agent/if:test_ctrl-cpp2-services",
    ],
)

cpp_library(
    name = "build_info_wrapper",
    srcs = [
        "facebook/BuildInfoWrapper.cpp",
    ],
    headers = [
        "BuildInfoWrapper.h",
    ],
    exported_deps = [
        "//common/base:build_info",
    ],
)

cpp_library(
    name = "fboss-types",
    srcs = [
        "PortDescriptorTemplate.cpp",
        "types.cpp",
    ],
    headers = [
        "PortDescriptorTemplate.h",
        "types.h",
    ],
    exported_deps = [
        "fbsource//third-party/fmt:fmt",
        ":switch_config-cpp2-types",
        "//folly:conv",
        "//folly/json:dynamic",
        "//folly/logging:logging",
    ],
    exported_external_deps = [
        "boost",
        ("boost", None, "boost_serialization"),
    ],
)

cpp_library(
    name = "fboss_event_base",
    headers = [
        "FbossEventBase.h",
    ],
    exported_deps = [
        ":agent_features",
        "//folly/io/async:async_base",
        "//folly/logging:logging",
    ],
)

cpp_library(
    name = "fboss-error",
    headers = [
        "FbossError.h",
        "FbossHwUpdateError.h",
        "SysError.h",
    ],
    exported_deps = [
        "//fboss/agent/if:fboss-cpp2-types",
        "//folly:conv",
        "//folly/logging:logging",
    ],
)

cpp_library(
    name = "load_agent_config",
    srcs = [
        "AgentConfig.cpp",
    ],
    headers = [
        "AgentConfig.h",
    ],
    exported_deps = [
        ":agent_config-cpp2-types",
        ":fboss-error",
        ":switch_config-cpp2-types",
        "//folly:file_util",
        "//thrift/lib/cpp2/protocol:protocol",
    ],
)

cpp_library(
    name = "platform_base",
    srcs = [
        "Platform.cpp",
        "PlatformPort.cpp",
    ],
    headers = [
        "Platform.h",
        "PlatformPort.h",
    ],
    exported_deps = [
        "fbsource//third-party/re2:re2",
        ":agent_dir_util",
        ":agent_features",
        ":fboss-error",
        ":fboss-types",
        ":fboss_event_base",
        ":load_agent_config",
        ":platform_config-cpp2-types",
        ":switch_config-cpp2-types",
        ":switchid_scope_resolver",
        ":switchinfo_utils",
        ":utils",
        "//fboss/agent/hw/switch_asics:switch_asics",
        "//fboss/agent/if:ctrl-cpp2-types",
        "//fboss/agent/platforms/common:platform_mapping",
        "//fboss/agent/state:state",
        "//fboss/lib/config:fboss_config_utils",
        "//fboss/lib/phy:phy-cpp2-types",
        "//fboss/lib/platforms:product-info",
        "//fboss/qsfp_service/if:transceiver-cpp2-types",
        "//folly:conv",
        "//folly:network_address",
        "//folly/futures:core",
        "//folly/io/async:async_base",
        "//folly/logging:logging",
        "//thrift/lib/cpp/util:enum_utils",
        "//thrift/lib/cpp2:server",
    ],
)

cpp_library(
    name = "hw_switch",
    srcs = [
        "HwSwitch.cpp",
        "HwSwitchRouteUpdateWrapper.cpp",
        "facebook/HwSwitch.cpp",
    ],
    exported_deps = [
        "fbsource//third-party/re2:re2",
        ":fboss-error",
        ":fboss-types",
        ":hwswitchcallback",
        ":load_agent_config",
        ":platform_base",
        ":route_update_wrapper",
        ":switch_config-cpp2-types",
        ":switch_state-cpp2-types",
        ":tx_packet_utils",
        ":utils",
        "//fb303:thread_cached_service_data",
        "//fboss/agent/hw:hardware_stats-cpp2-types",
        "//fboss/agent/hw:hw_switch_fb303_stats",
        "//fboss/agent/hw:hw_switch_warmboot_helper",
        "//fboss/agent/hw/switch_asics:switch_asics",
        "//fboss/agent/if:common-cpp2-types",
        "//fboss/agent/if:ctrl-cpp2-services",
        "//fboss/agent/if:ctrl-cpp2-types",
        "//fboss/agent/if:multiswitch_ctrl-cpp2-services",
        "//fboss/agent/rib:fib_updater",
        "//fboss/agent/rib:standalone_rib",
        "//fboss/agent/state:nodebase",
        "//fboss/agent/state:state",
        "//fboss/lib:common_file_utils",
        "//fboss/lib:hw_write_behavior",
        "//folly:file_util",
        "//folly:network_address",
        "//folly:thread_local",
        "//folly/logging:logging",
        "//folly/testing:test_util",
    ],
)

cpp_library(
    name = "async_logger",
    srcs = [
        "AsyncLogger.cpp",
    ],
    exported_deps = [
        ":async_logger_base",
    ],
)

cpp_library(
    name = "async_logger_base",
    srcs = [
        "AsyncLoggerBase.cpp",
    ],
    exported_deps = [
        ":fboss-error",
        "//fb303:service_data",
        "//folly:file",
        "//folly:file_util",
        "//folly:synchronized",
    ],
    exported_external_deps = [
        "gflags",
    ],
)

cpp_library(
    name = "async_packet_transport",
    headers = [
        "AsyncPacketTransport.h",
    ],
    exported_deps = [
        "//folly/io:iobuf",
        "//folly/io/async:async_socket_base",
        "//folly/io/async:async_socket_exception",
    ],
)

cpp_library(
    name = "sflow_shim_utils",
    srcs = [
        "SflowShimUtils.cpp",
    ],
    exported_deps = [
        "//folly/io:iobuf",
    ],
)

cpp_library(
    name = "packet",
    srcs = [
        "Packet.cpp",
        "TxPacket.cpp",
    ],
    headers = [
        "Packet.h",
        "RxPacket.h",
        "SwRxPacket.h",
        "TxPacket.h",
        "TxPacketObserver.h",
    ],
    exported_deps = [
        ":fboss-types",
        "//folly:network_address",
        "//folly/io:iobuf",
    ],
    exported_external_deps = [
        "gflags",
    ],
)

cpp_library(
    name = "gtest_defs",
    headers = ["GtestDefs.h"],
)

cpp_library(
    name = "fsdb_helper",
    srcs = [
        "FsdbHelper.cpp",
    ],
    headers = [
        "FsdbHelper.h",
    ],
    exported_deps = [
        "//fboss/fsdb/if:fsdb_model",
        "//fboss/fsdb/if:fsdb_oper-cpp2-types",
        "//folly/logging:logging",
    ],
)

cpp_library(
    name = "hwswitch_matcher",
    srcs = [
        "HwSwitchMatcher.cpp",
    ],
    headers = [
        "HwSwitchMatcher.h",
    ],
    exported_deps = [
        ":fboss-error",
        ":fboss-types",
        "//folly/logging:logging",
    ],
)

cpp_library(
    name = "switchid_scope_resolver",
    srcs = [
        "SwitchIdScopeResolver.cpp",
    ],
    headers = [
        "SwitchIdScopeResolver.h",
    ],
    exported_deps = [
        ":fboss-error",
        ":fboss-types",
        ":hwswitch_matcher",
        ":switchinfo_utils",
        "//fboss/agent/state:state",
    ],
    exported_external_deps = [
        ("boost", None, "boost_container"),
    ],
)

cpp_library(
    name = "hwswitchcallback",
    srcs = [
        "L2Entry.cpp",
    ],
    headers = [
        "HwSwitchCallback.h",
        "L2Entry.h",
    ],
    exported_deps = [
        ":fboss-types",
        ":packet",
        "//fboss/agent/if:ctrl-cpp2-types",
        "//fboss/agent/if:multiswitch_ctrl-cpp2-types",
        "//fboss/agent/rib:standalone_rib",
        "//fboss/agent/state:state",
        "//folly:network_address",
    ],
)

cpp_library(
    name = "hw_switch_handler",
    srcs = [
        "HwSwitchHandler.cpp",
    ],
    headers = [
        "HwSwitchHandler.h",
    ],
    exported_deps = [
        ":fboss-types",
        ":fboss_event_base",
        ":hwswitchcallback",
        ":load_agent_config",
        ":switch_config-cpp2-types",
        ":utils",
        "//fboss/agent/if:multiswitch_ctrl-cpp2-services",
        "//fboss/agent/state:state",
        "//fboss/lib:hw_write_behavior",
        "//folly/futures:core",
    ],
)

cpp_library(
    name = "monolithic_hw_switch_handler",
    srcs = [
        "single/MonolithicHwSwitchHandler.cpp",
    ],
    headers = [
        "single/MonolithicHwSwitchHandler.h",
    ],
    exported_deps = [
        ":fboss_init_h",
        ":hw_switch",
        ":hw_switch_handler",
        ":packet",
        ":platform_base",
        "//fboss/agent/hw:hw_switch_fb303_stats",
    ],
)

cpp_library(
    name = "multi_switch_hw_switch_handler",
    srcs = [
        "mnpu/MultiSwitchHwSwitchHandler.cpp",
    ],
    headers = [
        "mnpu/MultiSwitchHwSwitchHandler.h",
    ],
    exported_deps = [
        ":agent_features",
        ":core",
        ":hw_switch_handler",
        ":packet",
        ":stats",
        "//fboss/agent/if:multiswitch_ctrl-cpp2-services",
        "//fboss/agent/state:state",
    ],
)

cpp_library(
    name = "agent_dir_util",
    srcs = [
        "AgentDirectoryUtil.cpp",
    ],
    headers = ["AgentDirectoryUtil.h"],
    exported_deps = [
        "//folly/logging:logging",
    ],
    exported_external_deps = [
        "gflags",
    ],
)

cpp_library(
    name = "state_observer",
    headers = [
        "StateObserver.h",
    ],
    exported_deps = [
        "//fboss/agent/state:state",
    ],
    exported_external_deps = [
        "boost",
    ],
)

cpp_library(
    name = "hwagent",
    srcs = [
        "HwAgent.cpp",
    ],
    headers = [
        "HwAgent.h",
    ],
    exported_deps = [
        ":fboss_init_h",
        ":hw_switch",
        ":load_agent_config",
        ":platform_base",
    ],
    exported_external_deps = [
        "gflags",
    ],
)

cpp_library(
    name = "hwagent-main",
    srcs = [
        "HwAgentMain.cpp",
        "facebook/Main.cpp",
    ],
    headers = [
        "HwAgentMain.h",
    ],
    undefined_symbols = True,
    exported_deps = [
        ":agent_features",
        ":fboss_common_init",
        ":fboss_init_h",
        ":hw_switch",
        ":hwagent",
        ":setup_thrift",
        ":split_agent_thrift_syncer",
        ":test_utils",
        ":utils",
        "//common/fb303/cpp:default_control",
        "//fb303:logging",
        "//fb303:service_data",
        "//fboss/agent/facebook:version_h",
        "//fboss/agent/hw/switch_asics:switch_asics",
        "//fboss/agent/hw/test:hw_test_thrift_handler_h",
        "//fboss/agent/state:state",
        "//fboss/lib:common_file_utils",
        "//fboss/lib/restart_tracker:restart_time_tracker",
        "//folly/logging:init",
        "//folly/logging:logging",
    ],
    exported_external_deps = [
        "gflags",
    ],
)

cpp_library(
    name = "multiswitch_service",
    srcs = [
        "MultiSwitchThriftHandler.cpp",
    ],
    headers = [
        "MultiSwitchThriftHandler.h",
    ],
    exported_deps = [
        ":core",
        ":packet",
        ":stats",
        "//fboss/agent/if:multiswitch_ctrl-cpp2-services",
    ],
)

cpp_library(
    name = "route_update_wrapper",
    srcs = [
        "RouteUpdateWrapper.cpp",
    ],
    exported_deps = [
        ":address_utils",
        ":fboss-types",
        ":switch_config-cpp2-types",
        ":switchid_scope_resolver",
        "//fboss/agent/if:ctrl-cpp2-types",
        "//fboss/agent/rib:fib_updater",
        "//fboss/agent/rib:standalone_rib",
        "//fboss/agent/state:state",
        "//folly:network_address",
        "//folly/logging:logging",
    ],
)

cpp_library(
    name = "split_agent_thrift_syncer",
    srcs = [
        "mnpu/FdbEventSyncer.cpp",
        "mnpu/HwSwitchStatsSinkClient.cpp",
        "mnpu/IpcHealthMonitor.cpp",
        "mnpu/LinkChangeEventSyncer.cpp",
        "mnpu/OperDeltaSyncer.cpp",
        "mnpu/RxPktEventSyncer.cpp",
        "mnpu/SplitAgentThriftSyncer.cpp",
        "mnpu/SplitAgentThriftSyncerClient.cpp",
        "mnpu/SwitchReachabilityChangeEventSyncer.cpp",
        "mnpu/TxPktEventSyncer.cpp",
    ],
    headers = [
        "mnpu/FdbEventSyncer.h",
        "mnpu/HwSwitchStatsSinkClient.h",
        "mnpu/IpcHealthMonitor.h",
        "mnpu/OperDeltaSyncer.h",
        "mnpu/RxPktEventSyncer.h",
        "mnpu/SplitAgentThriftSyncer.h",
        "mnpu/SplitAgentThriftSyncerClient.h",
        "mnpu/SwitchReachabilityChangeEventSyncer.h",
        "mnpu/TxPktEventSyncer.h",
    ],
    exported_deps = [
        ":agent_features",
        ":hw_switch",
        ":hwswitchcallback",
        ":multiswitch_service",
        ":packet",
        "//fb303:service_data",
        "//fb303:thread_cached_service_data",
        "//fboss/agent/state:state",
        "//fboss/lib:common_thrift_utils",
        "//fboss/lib/thrift_service_client:thrift-service-client",
        "//folly:cancellation_token",
        "//folly:synchronized",
        "//folly/coro:async_scope",
        "//folly/coro:blocking_wait",
        "//folly/coro:bounded_queue",
        "//folly/coro:unbounded_queue",
        "//folly/io/async:async_base",
        "//folly/io/async:scoped_event_base_thread",
        "//folly/logging:logging",
        "//thrift/lib/cpp2/async:pooled_request_channel",
        "//thrift/lib/cpp2/async:reconnecting_request_channel",
        "//thrift/lib/cpp2/async:retrying_request_channel",
        "//thrift/lib/cpp2/async:rocket_client_channel",
    ],
    exported_external_deps = [
        "gflags",
    ],
)

cpp_library(
    name = "thrifthandler_utils",
    srcs = [
        "ThriftHandlerUtils.cpp",
    ],
    headers = [
        "ThriftHandlerUtils.h",
    ],
    exported_deps = [
        ":fboss-error",
        ":fboss-types",
        ":switch_config-cpp2-types",
        "//fb303:service_data",
        "//fboss/agent/state:state",
        "//fboss/thrift_cow/visitors:visitors",
        "//folly:string",
    ],
)

cpp_library(
    name = "agent_initializer_h",
    headers = [
        "AgentInitializer.h",
    ],
)

cpp_library(
    name = "monolithic_agent_initializer",
    srcs = [
        "single/MonolithicAgentInitializer.cpp",
    ],
    headers = [
        "single/MonolithicAgentInitializer.h",
    ],
    exported_deps = [
        ":core",
        ":fboss_common_init",
        ":fboss_init_h",
        ":handler",
        ":hw_switch",
        ":hwagent",
        ":load_agent_config",
        ":monolithic_hw_switch_handler",
        ":platform_base",
        ":setup_thrift",
        ":sw_agent_initializer",
        "//fboss/lib:common_file_utils",
        "//fboss/lib/restart_tracker:restart_time_tracker",
        "//folly:network_address",
        "//folly:scope_guard",
        "//folly/executors:function_scheduler",
        "//folly/io/async:async_base",
        "//folly/io/async:async_signal_handler",
        "//folly/logging:init",
        "//folly/logging:logging",
        "//thrift/lib/cpp2:server",
    ],
    exported_external_deps = [
        "gflags",
    ],
)

cpp_library(
    name = "split_agent_initializer",
    srcs = [
        "mnpu/SplitSwAgentInitializer.cpp",
    ],
    headers = [
        "mnpu/SplitSwAgentInitializer.h",
    ],
    exported_deps = [
        ":agent_dir_util",
        ":core",
        ":multi_switch_hw_switch_handler",
        ":multiswitch_service",
        ":sw_agent_initializer",
        "//fboss/lib:common_file_utils",
        "//folly/io/async:async_base",
    ],
)

cpp_binary(
    name = "fboss_sw_agent",
    srcs = [
        "FbossSwAgent.cpp",
    ],
    deps = [
        ":fboss_common_init",
        ":load_agent_config",
        ":main-common",
        ":setup_thrift_prod",  # @manual
        ":split_agent_initializer",
    ],
)

cpp_binary(
    name = "fboss_sw_agent_test",
    srcs = [
        "FbossSwAgent.cpp",
    ],
    deps = [
        ":fboss_common_init",
        ":load_agent_config",
        ":main-common",
        ":setup_thrift_test",  # @manual
        ":split_agent_initializer",
    ],
)

cpp_library(
    name = "setup_thrift_prod",
    srcs = [
        "SetupThriftProd.cpp",
    ],
    exported_deps = [
        ":handler",
        ":setup_thrift",
    ],
)

cpp_library(
    name = "setup_thrift_test",
    srcs = [
        "SetupThriftTest.cpp",
    ],
    exported_deps = [
        ":setup_thrift",
        ":test_thrift_handler",
    ],
)

cpp_library(
    name = "sw_switch_warmboot_helper",
    srcs = [
        "SwSwitchWarmBootHelper.cpp",
    ],
    exported_deps = [
        ":agent_dir_util",
        ":async_logger",
        ":hw_asic_table",
        ":switch_state-cpp2-types",
        ":utils",
        "//fboss/agent/rib:standalone_rib",
        "//fboss/agent/state:state",
        "//fboss/lib:common_file_utils",
        "//fboss/lib:warm_boot_file_utils",
        "//folly:file_util",
        "//folly/logging:logging",
    ],
)

# fake_wedge_agent, links with fake_main and monolithic_agent_initializer.
# fake_main also links with emulation's main.  monolithic_agent_initializer
# links with  sw_agent_initializer. emulation's main redefine methods provided
# by fboss_common_init. so sw_agent_initializer can not link with
# fboss_common_init so linking with only header
cpp_library(
    name = "sw_agent_initializer",
    srcs = [
        "SwAgentInitializer.cpp",
    ],
    headers = ["SwAgentInitializer.h"],
    undefined_symbols = True,
    exported_deps = [
        ":agent_dir_util",
        ":agent_features",
        ":agent_initializer_h",
        ":core",
        ":fboss_common_init_h",  # @manual
        ":handler",
        ":hw_asic_table",
        ":setup_thrift",
        "//fboss/lib:common_file_utils",
        "//folly/executors:function_scheduler",
        "//thrift/lib/cpp2:server",
    ],
    exported_external_deps = [
        "gflags",
    ],
)

cpp_library(
    name = "agent_pre_start_exec",
    srcs = [
        "AgentPreStartExec.cpp",
        "facebook/AgentPreStartConfig.cpp",
    ],
    headers = [
        "facebook/AgentPreStartConfig.h",
    ],
    exported_deps = [
        ":agent_command_executor",
        ":agent_dir_util",
        ":agent_netwhoami",
        ":fboss-error",
        ":fboss_common_init",
        ":load_agent_config",
        ":switch_config-cpp2-types",
        "//fboss/agent/facebook:agent_pre_exec_drainer",
        "//fboss/lib:common_file_utils",
        "//fboss/lib:common_utils",
        "//folly/logging:logging",
    ],
)

cpp_binary(
    name = "agent_pre_start_exec_runner",
    srcs = [
        "AgentPreStartExecRunner.cpp",
    ],
    deps = [
        ":agent_pre_start_exec",
        ":fboss-error",
        "//folly/init:init",
        "//folly/logging:init",
        "//folly/logging:logging",
    ],
    external_deps = [
        "gflags",
    ],
)

cpp_library(
    name = "agent_netwhoami",
    srcs = [
        "facebook/AgentNetWhoAmI.cpp",
    ],
    headers = [
        "AgentNetWhoAmI.h",
        "facebook/AgentNetWhoAmIImpl.h",
    ],
    exported_deps = [
        "//fboss/lib:common_file_utils",
        "//neteng/netwhoami/lib/cpp:recover",
    ],
)

cpp_library(
    name = "agent_fsdb_sync_manager",
    srcs = [
        "AgentFsdbSyncManager.cpp",
        "AgentFsdbSyncManager-computeOperDelta.cpp",
    ],
    exported_deps = [
        ":agent_info-cpp2-types",
        ":switch_reachability-cpp2-types",
        ":switch_state-cpp2-types",
        "//configerator/structs/neteng/fboss/bitsflow:bitsflow-cpp2-types",
        "//fboss/agent/state:state",
        "//fboss/fsdb/client:fsdb_syncer",
        "//fboss/fsdb/common:utils",
        "//fboss/fsdb/if:fsdb_model",
        "//fboss/lib:tuple_utils",
    ],
)

cpp_library(
    name = "agent_command_executor",
    srcs = [
        "AgentCommandExecutor.cpp",
    ],
    exported_deps = [
        "//fboss/lib:common_utils",
    ],
)

cpp_library(
    name = "agent_features",
    srcs = [
        "AgentFeatures.cpp",
    ],
    exported_external_deps = [
        "gflags",
    ],
)

cpp_library(
    name = "loadbalancer_utils",
    srcs = [
        "LoadBalancerUtils.cpp",
    ],
    exported_deps = [
        ":switch_config-cpp2-types",
        "//folly:network_address",
        "//folly/hash:hash",
    ],
)

cpp_library(
    name = "hw_asic_table",
    srcs = [
        "HwAsicTable.cpp",
    ],
    exported_deps = [
        ":fboss-error",
        ":fboss-types",
        ":utils",
        "//fboss/agent/hw/switch_asics:switch_asics",
        "//fboss/agent/platforms/common:platform_mapping_utils",
        "//fboss/lib/platforms:product-info",
    ],
)

cpp_library(
    name = "test_utils",
    srcs = [
        "TestUtils.cpp",
    ],
    exported_deps = [
        ":agent_dir_util",
        ":load_agent_config",
        "//fboss/lib:common_file_utils",
        "//folly/logging:logging",
    ],
)

cpp_library(
    name = "tx_packet_utils",
    srcs = [
        "TxPacketUtils.cpp",
    ],
    exported_deps = [
        ":hw_asic_table",
        ":switchid_scope_resolver",
        ":utils",
        "//fboss/agent/state:state",
    ],
)

cpp_unittest(
    name = "ipc_health_monitor_test",
    srcs = [
        "mnpu/test/IpcHealthMonitorTest.cpp",
    ],
    deps = [
        ":ipc_health_monitor",
        "//fb303:service_data",
        "//folly/io/async:async_base",
        "//folly/io/async/test:event_base_test_lib",
        "//folly/logging:logging",
    ],
)

ci_sandcastle(
    name = "build_fboss_fbpkg",
    alias = "build_fboss_fbpkg_ci",
    args = {
        "steps": [
            {
                "name": "Build fboss fbkg targets",
                "shell": "buck2 build //fbcode/fboss/agent/fbpkg/...",
            },
        ],
    },
    capabilities = {
        "tenant": "default-tenant",
        "type": "fbcode",
        "vcs": "full-fbsource",
    },
    # Adding triggers for raw inputs (for changes in asic_vendor_config) and generated outputs
    ci_srcs = [
        "fbcode/fboss/agent/**",
    ],
    command = "SandcastleUniversalCommand",
    oncall = "fboss_agent",
)

cpp_library(
    name = "ipc_health_monitor",
    srcs = [
        "mnpu/IpcHealthMonitor.cpp",
    ],
    headers = [
        "mnpu/IpcHealthMonitor.h",
    ],
    exported_deps = [
        "//fb303:service_data",
        "//fb303:thread_cached_service_data",
        "//folly:cancellation_token",
        "//folly:synchronized",
        "//folly/io/async:async_base",
        "//folly/logging:logging",
    ],
)

export_file(name = "Main.cpp")

sai_main_all()
